#include "quaternionindicator.h"

unsigned char QuaternionIndicator::indCount = 0;

QuaternionIndicator::QuaternionIndicator(QWidget *parent) :
    QWidget(parent)
{
    indCount++;
    indicatorId = indCount;

    setFixedSize(130,155);

    indLb = new QLabel("IMU " + QString::number(indicatorId));
    indLb->setAlignment(Qt::AlignCenter);
    aLe = new QLineEdit();
    bLe = new QLineEdit();
    cLe = new QLineEdit();
    dLe = new QLineEdit();

    QGridLayout *gLa = new QGridLayout();
    gLa->addWidget(indLb, 0, 1);
    gLa->addWidget(new QLabel("a(w)"), 1, 0);
    gLa->addWidget(new QLabel("b(x)"), 2, 0);
    gLa->addWidget(new QLabel("c(y)"), 3, 0);
    gLa->addWidget(new QLabel("d(z)"), 4, 0);
    gLa->addWidget(aLe, 1, 1);
    gLa->addWidget(bLe, 2, 1);
    gLa->addWidget(cLe, 3, 1);
    gLa->addWidget(dLe, 4, 1);
    gLa->setRowStretch(5,1);

    QGroupBox *grbox = new QGroupBox();
    grbox->setLayout(gLa);

    QVBoxLayout *mainLy = new QVBoxLayout();
    mainLy->addWidget(grbox);

    setLayout(mainLy);

    this->setStyleSheet( "border-radius: 5px; "
                         "border: 1px solid black;"
                         "border: 2px groove gray;"
                         "background-color:grey;");

}

void QuaternionIndicator::setValue(const QQuaternion &q)
{
    aLe->setText(QString::number(q.scalar(), 'g', 3));
    bLe->setText(QString::number(q.x(), 'g', 3));
    cLe->setText(QString::number(q.y(), 'g', 3));
    dLe->setText(QString::number(q.z(), 'g', 3));
}



